package gui;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

public class GuiUtilities {

	public static JMenuItem fitMenuItem(JComponent comp,String label, ActionListener action, boolean enabled, int keycode) {
		JMenuItem ret = new JMenuItem(label);
		ret.addActionListener(action);
		ret.setEnabled(enabled);
		comp.add(ret);
		ret.setAccelerator(
				KeyStroke.getKeyStroke(
				        keycode, ActionEvent.ALT_MASK));
		return ret;
	}
	
	public static JLabel fitNewLabel(JComponent comp, GridBagLayout gridbag, GridBagConstraints layoutConstraint, String text) {
		JLabel ret = new JLabel(text);
		ret.setFont(new Font("Helvetica", Font.PLAIN, 13));
		gridbag.setConstraints(ret,layoutConstraint);
		comp.add(ret);
		return ret;
	}
	
	public static JLabel fitNewLabel(JComponent comp,GridBagLayout gridbag, GridBagConstraints layoutConstraint, String text, String fontName, int style, int size) {
		JLabel r = fitNewLabel(comp,gridbag, layoutConstraint, text);
		r.setFont(new Font(fontName, style, size));
		return r;
	}
}
